for i, security in enumerate(hp_algo.interesting_stocks):
display(HTML('<h4>{}</h4>'.format(security)))
fig = plt.figure(i, figsize=(14,20))
subplot_def = 710
subplot_def += 1
ax = fig.add_subplot(subplot_def)
ax.set_title('Index performance: {:.1f}%'.format(index_performance), fontsize=15)
ax.set_ylabel('%')
ax.plot(index_data.index, index_data['^omx']/index_data['^omx'][0]*100-100, color='magenta', label='^omx')
ax.legend(loc='best')
ax.grid()
subplot_def += 1
stock_performance = hp_algo.data[security][-1] / hp_algo.data[security][0]*100-100
ax = fig.add_subplot(subplot_def)
ax.set_title('Stock performance: {:.1f}%'.format(stock_performance), fontsize=15)
ax.set_ylabel('%', color='blue')
ax.plot(hp_algo.data.index, hp_algo.data[security] / hp_algo.data[security][0]*100-100, label=security)
ax.legend(loc='best')
ax.grid()
ax2 = ax.twinx()
ax2.plot(hp_algo.data.index, hp_algo.data[security], color='red')
ax2.set_ylabel('sek', color='red')
subplot_def += 1
ax = fig.add_subplot(subplot_def)
ax.plot(hp_algo.xhat.index, hp_algo.xhat[security], label='xhat')
ax.plot(hp_algo.recorder.index, hp_algo.recorder[security+'.xhat'], label='xhat', color='green')
ax.legend(loc='best')
ax.grid()
ax2 = ax.twinx()
ax2.plot(hp_algo.data.index, hp_algo.data[security], color='red')
ax2.set_ylabel('sek', color='red')
subplot_def += 1
ax = fig.add_subplot(subplot_def)
ax.plot(hp_algo.xhat.index, hp_algo.derivitative, label='xhat der')
ax.plot(hp_algo.recorder.index, hp_algo.recorder[security+'.derivitative'], color='green', label='xhat der')
ax.legend(loc='best')
ax.grid()
ax.set_yticks([-0.2, 0, 0.2], minor=False)
#ax.set_yticks([0.3,0.55,0.7], minor=True)
ax.yaxis.grid(True, which='major')
#ax.yaxis.grid(True, which='minor')
subplot_def += 1
ax = fig.add_subplot(subplot_def)
ax.plot(hp_algo.xhat.index, hp_algo.derivitative_2, label='xhat 2nd der')
ax.plot(hp_algo.recorder.index, hp_algo.recorder[security+'.derivitative_2'], color='green', label='xhat 2nd der')
ax.legend(loc='best')
ax.grid()
subplot_def += 1
ax = fig.add_subplot(subplot_def)
ax.plot(hp_algo.buy_sell_hold_signal.index, hp_algo.buy_sell_hold_signal[security+'.buy_sell_hold_signal'])
ax.set_ylim([-1, 2])
subplot_def += 1
worth_percentage = hp_algo.recorder['worth'] / hp_algo.recorder['worth'][0]*100-100
ax = fig.add_subplot(subplot_def)
ax.plot(hp_algo.recorder.index, hp_algo.recorder['worth'])
ax2 = ax.twinx()
ax2.plot(hp_algo.data.index, worth_percentage, color='red')
ax2.set_ylabel('%', color='red')
fig.tight_layout()
plt.show()